/**
 * 获取商品的评价tags
 * @param {String} id - 商品ID
 */

import { useAxiosWithAuth } from "@/utils/useAxiosWidthAuth";
import { useEffect, useState } from "react";
export const useFindCommentInfoByGoods = function (id: string) {
  const axios = useAxiosWithAuth();
  const [result, setResult] = useState<any>();
  useEffect(() => {
    async function findCommentInfoByGoods() {
      const res: any = await axios({
        method: "get",
        url: `https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate`,
      });
      setResult(res.result);
    }
    findCommentInfoByGoods();
  }, [id]);
  return { result };
};

/**
 * 获取商品的评价列表
 * @param {String} id - 商品ID
 */

export const useFindCommentList = function (id: string, params: any) {
  const axios = useAxiosWithAuth();
  const [result, setResult] = useState<any>();
  useEffect(() => {
    async function findCommenList() {
      const res: any = await axios({
        method: "get",
        url: `https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate/page`,
        params: params,
      });
      setResult(res.result);
    }
    findCommenList();
  }, [id, params]);
  return { result };
};
